package com.googlecode.gwtresume.client.render;


import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.googlecode.gwtresume.client.Renderer;


public class ModernRenderer extends UnstyledRenderer implements Renderer {
	
	public ModernRenderer() {
		super();
	}
	
	public void render(VerticalPanel content) {
		
		HorizontalPanel header = renderHeader();
		VerticalPanel main = newVerticalPanel("main");
		main.add(renderProfile());
		main.add(renderExperience());

		halign = HasAlignment.ALIGN_RIGHT;
		VerticalPanel side = newVerticalPanel("side", halign);
		side.add(renderSkills());
		side.add(renderEducation());
		halign = null;
		
		HorizontalPanel body = newHorizontalPanel("body", main, side);		
		
		content.add(header);
		content.add(body);
		content.add(renderFooter());

	}
	protected String formatPhone(String phone) {
		if (phone.matches(constants.phonePattern())) return phone.replaceAll(constants.phonePattern(), "$1 | $2.$3");
		else return phone;
	}
	protected Label newSectionHeader(String header) {
		return super.newSectionHeader(header.toLowerCase());
	}
	
	protected Label newLabel(String style, String text, boolean wrap) {
		String txt = text;
		
		if ("title".equals(style) || "employer".equals(style) || "period".equals(style)) 
			txt = text.toUpperCase();
		else if("skill_header".equals(style))
			txt = text.toLowerCase();
		
		return super.newLabel(style, txt, wrap);
	}

}
